package com.atguigu.gulimall.product.config;

import jodd.util.concurrent.ThreadFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.concurrent.*;

/**
 * @Author:Panghl
 * @Description:
 * @Date: Created in 21:51 2022/7/11
 * @Modified By:
 */
@Configuration
public class MyThreadConfig {

@Resource
private ThreadPoolConfigProperties poolConfigProperties;


    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(poolConfigProperties.getCoreSize(),
                poolConfigProperties.getMaxSize(),
                poolConfigProperties.getKeepAliveTime(),
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(),new ThreadPoolExecutor.DiscardPolicy());
    }


}
